#!/bin/bash -e

function info() {
echo Usage: `basename $0` '[-s] r1.fq [r2.fq]'
exit 2
}

while getopts  ":p:f:t:s:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		t) threads=$OPTARG;;
        s) sample_name=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))

if [ $# -lt 1 ]; then info; fi

. $var

ref_path=$(dirname $ref_genome)/bismark

echo $ref_path

# -I minimum insert size
# -X maximum insert size 500
# -p bowtie threads
# --non_bs_mm Optionally outputs an extra column specifying the number of non-bisulfite mismatches a read
# --non_directional The sequencing library was constructed in a non strand-specific manner
# --basename ? bismark

bismark --non_directional --unmapped --nucleotide_coverage --prefix $out_prefix --non_bs_mm --rg_tag --rg_id $sample_name --rg_sample $sample_name --multicore 2 -X 400 -I 60 -p ${threads:=4} $ref_path -1 $1 -2 $2 || bismark -p ${threads:=4} $ref_path $1

. $cmd_done